package com.springcloud.servicemiya.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author chenkuan
 * @version v1.0
 * @desc
 * @date 2019/4/25 025 13:02
 */
@Slf4j
@RestController
public class HelloController {

	@Autowired
	private RestTemplate restTemplate;

	@RequestMapping("/hi")
	public String home() {
		log.info("hi is being called");
		return "hi i'm miya!";
	}

	@RequestMapping("/miya")
	public String callHome(String name) {
		log.info("hello " + name + " from service-hi");
		log.info("calling trace service-miya to service-hi");
		return restTemplate.getForObject("http://localhost:8762/info?name=" + name, String.class);
	}

}
